import { service as request } from '@/utils/request_web'
import store from '@/store'

export function login(data) {
  return request({
    url: '/User/login/',
    method: 'get',
    // auth: { username: store.getters.username, password: store.getters.pass },
    params: data
  })
}

export function getInfo(id) {
  return request({
    url: `/User/userinfo/${id}/`,
    method: 'get'
    // params: id
  })
}

export function logout() {
  return request({
    url: '/User/logout/',
    method: 'get'
  })
}

export function getUserLabel() {
  return request({
    url: `/User/label/`,
    method: 'get'
  })
}
// 请求部门信息
export function getUserDepartment(data) {
  return request({
    url: `/User/department/`,
    method: 'get',
    params: data
  })
}
// 创建部门信息
export function postUserDepartment(data) {
  return request({
    url: `/User/department/`,
    method: 'post',
    data
  })
}
// 修改部门信息
export function patchUserDepartment(id, data) {
  return request({
    url: `/User/department/${id}/`,
    method: 'patch',
    data
  })
}
// 删除部门信息
export function deleteUserDepartment(id) {
  return request({
    url: `/User/department/${id}/`,
    method: 'delete'
  })
}
// 请求外部单位
export function getOuterUserDepartment(data) {
  return request({
    url: `/User/OuterUser`,
    method: 'get',
    params: data
  })
}
// 获取所有用户信息列表
export function getAllUser(data) {
  return request({
    url: `/User/userinfo/`,
    method: 'get',
    params: data
  })
}
// 创建用户
export function postCreateUser(data) {
  return request({
    url: `/User/userinfo/`,
    method: 'post',
    data: data
  })
}
// 编辑用户
export function patchUpdateUser(id, data) {
  return request({
    url: `/User/userinfo/${id}/`,
    method: 'patch',
    data: data
  })
}
// 创建用户
export function deleteUser(id) {
  return request({
    url: `/User/userinfo/${id}/`,
    method: 'delete'
  })
}
// 获取所有角色列表
export function getAllRole() {
  return request({
    url: `/User/group/`,
    method: 'get'
  })
}
// 通过id获取对应用户名称
export function getUsernameById({ userid }) {
  return request({
    url: `/User/FindUsername/`,
    method: 'post',
    data: userid
  })
}
// 获取群组列表
export function getShareGroupList(params) {
  return request({
    url: `/User/share_group/`,
    params
  })
}
// 创建群组
export function createShareGroup(data) {
  return request({
    url: `/User/share_group/`,
    method: 'post',
    data
  })
}
// 修改群组信息，包括人员选择
export function updateShareGroup(id, data) {
  return request({
    url: `/User/share_group/${id}/`,
    method: 'patch',
    data
  })
}
// 删除群组
export function deleteShareGroup(id) {
  return request({
    url: `/User/share_group//${id}`,
    method: 'delete',
  })
}
// 更新群组排序后的用户order
export function updateGroupOrderSort(groupId, data) {
  return request({
    url: `/User/share_group/${groupId}/`,
    method: 'patch',
    data
  })
}
// 更新部门排序后的用户order
export function updateDepartmentOrderSort(data) {
  return request({
    url: `/User/sortuser/`,
    method: 'post',
    data
  })
}
// 启动流程后发送短信
export function postSendShortInfo(data) {
  return request({
    url: `/User/senderApproval/`,
    method: 'post',
    data
  })
}

